package edu.sctu.zcy.month201506.day20150618.httptest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by user24 on 2015/6/18.
 */
public class HttpRequestGet {

    public String sendGet(String url,String param){

        String result = "";
        BufferedReader in = null;
        try {

            String urlNameString = url + "?" + param;
            URL realUrl = new URL(urlNameString);
            URLConnection urlConnection = realUrl.openConnection();

//            urlConnection.setRequestProperty("accept","*/*");
//            urlConnection.setRequestProperty("connection","Keep-Alive");
//            urlConnection.setRequestProperty("");

            urlConnection.connect();
            in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null){
                result += line;
            }

            in.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }




        return result;
    }
}

